home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / ODF / OS / FWGraphx / SLColor.cpp < prev    next >
Encoding:
Text File  |  1996-12-16  |  3.6 KB  |  132 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLColor.cpp
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef SLCOLOR_H
  13. #include "SLColor.h"
  14. #endif
  15.  
  16. #ifdef FW_BUILD_MAC
  17. #pragma segment FW_Graphics
  18. #endif
  19.  
  20. //========================================================================================
  21. // Color conversion functions
  22. //========================================================================================
  23.  
  24. #ifdef FW_BUILD_WIN
  25.  
  26. #if 0
  27.  
  28. // The OS static library precompiles a header file which puts precompiled
  29. //    debug info into FWRegEdt.obj.  We need to force a reference to that file
  30. //    from somewhere in this DLL.
  31.  
  32. extern "C"
  33. {
  34.     HRESULT WINAPI ODFRegisterServer();
  35.     HRESULT WINAPI ODFUnregisterServer();
  36. }
  37.  
  38. #ifdef FW_DEBUG
  39.  
  40. short FW_gPartRegistryResourceID = -1;
  41. static HRESULT (WINAPI *registerFunc)() = ODFRegisterServer;
  42.  
  43. #endif
  44.  
  45. #endif
  46.  
  47. //----------------------------------------------------------------------------------------
  48. //    FW_WinRGBQuadToColor
  49. //----------------------------------------------------------------------------------------
  50.  
  51. FW_SColor        SL_API
  52. FW_WinRGBQuadToColor(const RGBQUAD* rgbQuad)
  53. {
  54.     FW_SColor color;
  55.     FW_PrivSetRGB(color, rgbQuad->rgbRed, rgbQuad->rgbGreen, rgbQuad->rgbBlue);
  56.     return color;
  57. }
  58.  
  59. //----------------------------------------------------------------------------------------
  60. //    FW_WinRGBTripleToColor
  61. //----------------------------------------------------------------------------------------
  62.  
  63. FW_SColor        SL_API
  64. FW_WinRGBTripleToColor(const RGBTRIPLE* rgbTriple)
  65. {
  66.     FW_SColor color;
  67.     FW_PrivSetRGB(color, rgbTriple->rgbtRed, rgbTriple->rgbtGreen, rgbTriple->rgbtBlue);
  68.     return color;
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. //    FW_WinColorToRGBQuad
  73. //----------------------------------------------------------------------------------------
  74.  
  75. void            SL_API
  76. FW_WinColorToRGBQuad(FW_SColor rgb, RGBQUAD* rgbQuad)
  77. {
  78.     rgbQuad->rgbRed         = FW_PrivRGB_R(rgb);
  79.     rgbQuad->rgbGreen        = FW_PrivRGB_G(rgb);
  80.     rgbQuad->rgbBlue        = FW_PrivRGB_B(rgb);
  81.     rgbQuad->rgbReserved    = 0;
  82. }
  83.  
  84. //----------------------------------------------------------------------------------------
  85. //    FW_WinColorRGBTriple
  86. //----------------------------------------------------------------------------------------
  87.  
  88. void        SL_API
  89. FW_WinColorRGBTriple(FW_SColor rgb, RGBTRIPLE* rgbTriple)
  90. {
  91.     rgbTriple->rgbtRed        = FW_PrivRGB_R(rgb);
  92.     rgbTriple->rgbtGreen    = FW_PrivRGB_G(rgb);
  93.     rgbTriple->rgbtBlue        = FW_PrivRGB_B(rgb);
  94. }
  95.  
  96. #endif
  97.  
  98. #ifdef FW_BUILD_MAC
  99.  
  100. //----------------------------------------------------------------------------------------
  101. //    FW_MacRGBToColor
  102. //----------------------------------------------------------------------------------------
  103.  
  104. FW_SColor    SL_API
  105. FW_MacRGBToColor(const RGBColor* rgbColor)
  106. {
  107.     // No try block necessary - Do not throw
  108.     FW_SColor color;
  109.     FW_PrivSetRGB(color, rgbColor->red >> 8, rgbColor->green >> 8, rgbColor->blue >> 8);
  110.     return color;
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    FW_MacColorToRGB
  115. //----------------------------------------------------------------------------------------
  116.  
  117. void        SL_API
  118. FW_MacColorToRGB(FW_SColor rgb, RGBColor* rgbColor)
  119. {
  120.     // No try block necessary - Do not throw
  121.     rgbColor->red    = FW_PrivRGB_R(rgb);
  122.     rgbColor->red    |= rgbColor->red << 8;
  123.  
  124.     rgbColor->green    = FW_PrivRGB_G(rgb);
  125.     rgbColor->green    |= rgbColor->green << 8;
  126.  
  127.     rgbColor->blue    = FW_PrivRGB_B(rgb);
  128.     rgbColor->blue    |= rgbColor->blue << 8;
  129. }
  130.  
  131. #endif
  132.